import 'package:json_annotation/json_annotation.dart';
import 'package:lovify/core/network/model/pageable.dart';
import 'package:lovify/core/network/model/sort.dart';

part 'pagination.g.dart';

@JsonSerializable(genericArgumentFactories: true)
class Pagination<T> {
  final bool? last;
  final int? totalPages;
  final int? totalElements;
  final int? size;
  final int? number;
  final Sort? sort;
  final bool? first;
  final int? numberOfElements;
  final bool? empty;
  final Pageable? pageable;
  final List<T>? content;

  Pagination({
    this.last,
    this.totalPages,
    this.totalElements,
    this.size,
    this.number,
    this.sort,
    this.first,
    this.numberOfElements,
    this.empty,
    this.pageable,
    this.content,
  });

  factory Pagination.fromJson(
    Map<String, dynamic> json,
    T Function(Object? json) fromJsonT,
  ) =>
      _$PaginationFromJson(json, fromJsonT);
  Map<String, dynamic> toJson() => _$PaginationToJson(this, (json) => json);
}
